package com.servlet;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.jws.WebParam;

@Controller
public class conrith {

    @GetMapping("/save")
    public String save(@RequestParam(name = "name",defaultValue = "默认值") String name, String password){
        System.out.println("欢迎进入MVC");
        System.out.println(name+password);
        return "/sss.jsp";
    }

    @RequestMapping("/sun")
    public String sun(Model model){
        model.addAttribute("sun","你猜");
        return "/sss.jsp";
    }


    @RequestMapping("/nnx")
    public ModelAndView nnx(){
        System.out.println("你好欢迎来到Spring MVC课堂");
        ModelAndView modelAndView= new ModelAndView();
        modelAndView.addObject("realName","你猜");
        modelAndView.setViewName("hello");
        return modelAndView;
    }
}
